﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using QuanLyDatVe.DataAccessLayer;

namespace QLNHang.DAO
{
    public class NguyenLieuDAO
    {
        private ConnectDatabase cn = new ConnectDatabase();
        public DataTable LayNguyenLieu()
        {
            DataTable dt = new DataTable();
            cn.OpenDatabase();
            SqlCommand cmd = new SqlCommand("sp_LayNguyenLieu", cn.SqlConnect);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            cn.CloseDatabase();
            return dt;
        }

        internal void CapNhatSoLuong(int maNguyeLieu, int soLuong)
        {
            cn.OpenDatabase();
            SqlCommand cmd = new SqlCommand("sp_CapNhatSoLuong", cn.SqlConnect);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@maNguyenLieu", SqlDbType.Int).Value = maNguyeLieu;
            cmd.Parameters.Add("@soLuongTon", SqlDbType.Int).Value = soLuong;
            cmd.ExecuteNonQuery();
            cn.CloseDatabase();
        }
    }
}
